package com.jt.sys.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jt.common.vo.JsonResult;
import com.jt.sys.entity.SysMenu;
import com.jt.sys.service.SysMenuService;

@Controller
@RequestMapping("/menu/")
public class SysMenuController {
	@Autowired
	private SysMenuService sysMenuService;
	/**呈现菜单列表页面*/
	@RequestMapping("doMenuListUI")
	public String doMenuListUI(){
		return "sys/menu_list";
	}
	@RequestMapping("doFindObjects")
	@ResponseBody
	@RequiresPermissions("sys:menu:view")
	public JsonResult doFindObjects(){
		List<Map<String, Object>> list = sysMenuService.findObjects();
		return new JsonResult(list);
	}
	@RequestMapping("doDeleteObject")
	@ResponseBody
	@RequiresPermissions("sys:menu:del")
	public JsonResult doDeleteObject(Integer id){
		sysMenuService.deleteObject(id);
		return new JsonResult("delete ok!");
	}
	@RequiresPermissions("sys:menu:add")
	@RequestMapping("doMenuSaveEditUI")
	public String doMenuSaveEditUI(){
		return "sys/menu_edit";
	}
	@RequiresPermissions("sys:menu:update")
	@RequestMapping("doMenuUpdateEditUI")
	public String doMenuUpdateEditUI(){
		return "sys/menu_edit";
	}
	@RequestMapping("doFindZtreeMenuNodes")
	@ResponseBody
	public JsonResult doFindZtreeMenuNodes(){
		return new JsonResult(sysMenuService.findZtreeMenuNodes());
	}
	@RequestMapping("doSaveObject")
	@ResponseBody
	public JsonResult doSaveObject(SysMenu entity){
		sysMenuService.saveObject(entity);
		return new JsonResult("save ok");
	}
	@RequestMapping("doFindObjectById")
	@ResponseBody
	public JsonResult doFindObjectById(Integer id){
		Map<String, Object> map = sysMenuService.findObjectById(id);
		return new JsonResult(map);
	}
	@RequestMapping("doUpdateObject")
	@ResponseBody
	public JsonResult doUpdateObject(SysMenu entity){
		sysMenuService.updateObject(entity);
		return new JsonResult("update ok");
	}
}
